package com.dy.nygl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dy.nygl.mapper.DeviceMapper;
import com.dy.nygl.pojo.Device;
import com.dy.nygl.service.DeviceService;

@Service("deviceService")
public class DeviceServiceImpl implements DeviceService{

	@Resource(name="deviceDAO")
	private DeviceMapper deviceDAO;
	
	public List<Device> getDevice(int begin,int end) {
		List<Device> list = deviceDAO.getDevice();
		if(list != null && list.size() > 0) {
			if(list.size()>(end - begin)) {
				if(list.size() < end) {
					list = list.subList(begin, list.size());
				} else {
					list = list.subList(begin, end);
				}			
			}	
			return list;
		}
		return null;
	}
	
	public Device getDeviceById(int id) {
		return deviceDAO.getDeviceById(id);
	}
	
	public int getDeviceCount() {
		return deviceDAO.getDeviceCount();
	}

	public void adDevice(Device device) {
		deviceDAO.addDevice(device);
	}
	
	public void updateDevice(Device device) {
		deviceDAO.updateDevice(device);
	}
	
	public void deleteDevice(int id) {
		deviceDAO.deleteDevice(id);
	}
	
	public Device getDeviceByNum(String num) {
		return deviceDAO.getDeviceByNum(num);
	}
}
